package com.twu.solo;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: thoughtworker
 * Date: 10/10/13
 * Time: 1:16 PM
 * To change this template use File | Settings | File Templates.
 */
public class ManagerApp {
    private PrintStream printStream;
    private League league;
    private Menu mainMenu;
    private BufferedReader reader;

    public ManagerApp(Menu mainMenu, League league, PrintStream printStream, BufferedReader reader) {
        this.mainMenu = mainMenu;
        this.printStream = printStream;
        this.league = league;
        this.reader = reader;
    }


    public void app() throws IOException {
        mainMenu.printMenuOptions();
        respondToMenuUserInput();
    }


    public void respondToMenuUserInput() throws IOException {
        String userInput = reader.readLine();
        if(userInput.equals("1")) {
            league.printPlayers();
        } else if (userInput.equals("2")){
            printStream.println("Enter Player Name");
            getPlayerInfo();
        } else {
            printStream.println("Invalid Option");
        }
    }

    public void getPlayerInfo() throws IOException {
        String playerName = reader.readLine();
        league.printPlayerInfo(playerName);
    }
}
